package com.wander.designCreational.prototype;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author : WDYin
 * @Date : 2020/5/9
 * @Description :
 */
public class Prototype implements Cloneable {

    private Integer id;
    private String name;
    private Map<String, Double> map;

    @Override
    protected Prototype clone() throws CloneNotSupportedException {
        //基本类型进行克隆
        Prototype prototype = (Prototype) super.clone();
        //对每一个复杂类型分别进行克隆
        prototype.map = (Map<String, Double>) ((HashMap) this.map).clone();
        return prototype;
    }

    public Prototype(Integer id, String name, Map<String, Double> map) {
        this.id = id;
        this.name = name;
        this.map = map;
    }

    @Override
    public String toString() {
        return "Prototype{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", map=" + map +
                '}';
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Map<String, Double> getMap() {
        return map;
    }

    public void setMap(Map<String, Double> map) {
        this.map = map;
    }
}
